<template>
  <import-container
    :title="title"
    export-type="apiUrl"
    :file-code="fileCode"
    :export-url="exportUrl"
    :show-secret-level="props.tabParam.queryType !== '3'"
    :import-url="importUrl"
    :params="props.tabParam"
    :is-show-down-load="true"
    @close-drawer="closeDrawer"
    @finish="finish"
  />
</template>

<script setup lang="ts">
  import { ref, defineProps, onMounted, defineEmits } from 'vue';
  import importContainer from '@/common/components/batch-import/import-container.vue';

  const emit = defineEmits(['closeDrawer', 'success']);
  const props = defineProps({
    type: {
      type: String,
      default: '',
    },
    tabParam: {
      type: Object,
      default: null,
    },
  });
  const closeDrawer = () => {
    emit('closeDrawer');
  };
  const codeReflection: any = ref({
    1: 'require_requirereceiveBzjUrl',
    2: 'require_requirereceiveCpUrl',
    3: 'require_requirereceiveYclUrl',
    4: 'require_requirereceiveLzjUrl',
    5: 'require_requirereceiveDzjUrl',
  });
  const exportUrl = ref('');
  const fileCode = ref('');
  if (props.tabParam.queryType === '3') {
    fileCode.value = 'require_requirereceiveCloseUrl';
  } else {
    fileCode.value = codeReflection.value[props.tabParam.classType];
  }
  const importUrl = ref('');
  const title = ref('');
  // 完成
  const finish = (response: any, secretLevel: string) => {
    emit('success', response, secretLevel);
  };
  onMounted(() => {
    if (props.tabParam.queryType === '3') {
      title.value = '导入关闭Excel';
      importUrl.value =
        '/api/procurement/require/require-receive/doCloseImport';
    } else {
      title.value = '导入';
      importUrl.value = '/api/procurement/require/require-receive/doImport';
    }
  });
</script>
